package com.info.zhiduoduo.admin.controller;

import com.info.zhiduoduo.admin.model.formbean.crowdsource.TaxPaymentVoucherListFormBean;
import com.info.zhiduoduo.admin.model.formbean.entrust.EditEntrustProjectInvoiceFormBean;
import com.info.zhiduoduo.admin.model.formbean.companyParty.GetCompanyPartyFromBean;
import com.info.zhiduoduo.admin.model.formbean.invoice.*;
import com.info.zhiduoduo.admin.service.InvoiceService;
import com.info.zhiduoduo.common.annotation.DependOnEntity;
import com.info.zhiduoduo.common.annotation.LogEntity;
import com.info.zhiduoduo.common.annotation.LogParameter;
import com.info.zhiduoduo.common.annotation.ZddLog;
import com.info.zhiduoduo.common.constants.SmartResult;
import com.info.zhiduoduo.common.constants.system.ZddLogType;
import com.info.zhiduoduo.common.formbean.BaseListFormBean;
import com.info.zhiduoduo.common.formbean.BaseSimpleFormBean;
import com.info.zhiduoduo.core.service.common.DocService;
import com.info.zhiduoduo.repository.dto.crowdsource.TaxClearanceCertificateDto;
import com.info.zhiduoduo.repository.dto.invoice.CompanyCrowdsourceInvoiceBriefStatisticDto;
import com.info.zhiduoduo.repository.dto.invoice.CompanyInventoryDto;
import com.info.zhiduoduo.repository.dto.invoice.CompanyInventoryRecordDto;
import com.info.zhiduoduo.repository.dto.invoice.CostInvoiceListDto;
import com.info.zhiduoduo.repository.dto.invoice.InvoiceBriefDto;
import com.info.zhiduoduo.repository.dto.invoice.InvoiceInventoryDto;
import com.info.zhiduoduo.repository.dto.invoice.InvoiceInventoryRecordDto;
import com.info.zhiduoduo.repository.dto.invoice.MergeCostInvoiceListDto;
import com.info.zhiduoduo.repository.dto.invoice.QueryInvoiceDto;
import com.info.zhiduoduo.repository.entity.company.CompanyProject;
import com.info.zhiduoduo.repository.entity.crowdsource.CrowdsourceInvoice;
import com.info.zhiduoduo.repository.entity.invoice.*;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 * 发票管理
 *
 * @author bob
 * @since 2019/1/3 上午11:25
 */
@Api(tags = "发票管理")
@RestController
@RequestMapping("/invoice")
public class InvoiceController {

	@Autowired
	InvoiceService invoiceService;

	@Autowired
	DocService docService;

	/**
	 * 待开发票列表, 获取已验证过的项目列表
	 */
	@PostMapping("/list")
	public SmartResult invoiceList(@Valid @RequestBody BaseSimpleFormBean<InvoiceListFromBean> formBean) {
		return invoiceService.invoiceList(formBean);
	}

	/**
	 * 查询 待申请的 发票列表
	 *
	 * @param formBean
	 * @return
	 */
	@PostMapping("/pendingInvoiceList")
	public SmartResult pendingInvoiceList(@RequestBody BaseSimpleFormBean<InvoiceListFromBean> formBean) {
		return invoiceService.pendingInvoiceList(formBean);
	}

	@ApiOperation(" 项目策略性待开票列表")
	@PostMapping("/strategylist")
	public SmartResult<InvoiceBriefDto> strategyInvoiceList(@RequestBody BaseSimpleFormBean<InvoiceListFromBean> formBean) {
		return invoiceService.strategyInvoiceList(formBean);
	}

	@ApiOperation("智众包项目策略性待开票列表")
	@PostMapping("/crowdsourceStrategyInvoiceList")
	public SmartResult<InvoiceBriefDto> crowdsourceStrategyInvoiceList(@RequestBody BaseSimpleFormBean<InvoiceListFromBean> formBean) {
		return invoiceService.crowdsourceStrategyInvoiceList(formBean);
	}

	@ZddLog(type = ZddLogType.UPDATE, name = "设置为策略性待开票", entities = @LogEntity(entity = Invoice.class, parameters = @LogParameter(fields
			= "id", parameters = "formBean.reqdata.invoiceid")))
	@ApiOperation("设置为策略性待开票(目前只有普通项目可以设置, 众包项目不行)")
	@PostMapping("/setStrategyInvocie")
	public SmartResult setStrategyInvoice(@Valid @RequestBody BaseListFormBean<StrategyInvoiceFormBean> formBean) {
		return invoiceService.setStrategyInvoice(formBean);
	}

	/**
	 * 获取未提交的发票信息
	 */
	@ZddLog(type = ZddLogType.QUERY, name = "获取未提交的发票信息")
	@PostMapping("/create")
	public SmartResult createInvoice(@RequestBody BaseSimpleFormBean<Integer> formBean) {
		return invoiceService.createInvoice(formBean);
	}

	/**
	 * 获取开票详情
	 */
	@PostMapping("/detail")
	public SmartResult getInvoiceDetail(@RequestBody BaseSimpleFormBean<Integer> formBean) {
		return invoiceService.getInvoiceDetail(formBean);
	}

	/**
	 * 提交修改发票内容
	 */
	@ZddLog(type = ZddLogType.UPDATE, name = "提交修改发票内容", entities = @LogEntity(entity = Invoice.class, parameters =
	@LogParameter(parameters = "formBean.reqdata.invoiceid")))
	@PostMapping("/submit")
	public SmartResult submit(@RequestBody BaseSimpleFormBean<SubmitInvoiceFormBean> formBean) {
		return invoiceService.submit(formBean);
	}

	/**
	 * 提交修改发票内容
	 */
	@ZddLog(type = ZddLogType.UPDATE, name = "确认支付并开票", entities = @LogEntity(entity = Invoice.class, parameters =
	@LogParameter(parameters = "formBean.reqdata.invoiceid")))
	@ApiOperation("确认支付并开票")
	@PostMapping("/confirmPayAndSubmit")
	public SmartResult confirmPayAndSubmit(@RequestBody BaseSimpleFormBean<SubmitInvoiceFormBean> formBean) {
		return invoiceService.confirmPayAndSubmit(formBean);
	}

	/**
	 * 确认已开发票,输入快递单号
	 */
	@ZddLog(type = ZddLogType.UPDATE, name = "确认已开发票,", entities = @LogEntity(entity = Invoice.class, parameters = @LogParameter(fields =
			"id", parameters = "formBean.reqdata.id")))
	@PostMapping("/confirm")
	public SmartResult confirm(@RequestBody BaseSimpleFormBean<ConfirmInvoiceFormBean> formBean) {
		return invoiceService.confirm(formBean);
	}

	/**
	 * 编辑发票备注
	 */
	@ZddLog(type = ZddLogType.UPDATE, name = "编辑发票备注", entities = @LogEntity(entity = Invoice.class, parameters =
	@LogParameter(parameters = "formBean.reqdata.id")))
	@PostMapping("/editRemark")
	public SmartResult editRemark(@RequestBody BaseSimpleFormBean<EditRemarkFormBean> formBean) {
		return invoiceService.editRemark(formBean);
	}

	@ZddLog(type = ZddLogType.UPDATE, name = "编辑发票作废", entities = @LogEntity(entity = Invoice.class, parameters =
	@LogParameter(parameters = "formBean.reqdata.invoiceId")))
	@ApiOperation("编辑发票作废")
	@PostMapping("/editInvoiceCancellation")
	public SmartResult editInvoiceCancellation(@RequestBody @Validated BaseSimpleFormBean<EditInvoiceStateFormBean> formBean) {
		return invoiceService.editInvoiceCancellation(formBean);
	}

	/**
	 * 智众包项目的发票列表
	 */
	@PostMapping("/crowdsourceInvoiceList")
	public SmartResult crowdsourceInvoiceList(@RequestBody BaseSimpleFormBean<InvoiceListFromBean> formBean) {
		return invoiceService.crowdsourceInvoiceList(formBean);
	}

	@ApiOperation(value = "查询企业智众包发票当月统计数据", notes = "reqdata 传企业id")
	@PostMapping("/companyCrowdsourceInvoiceStatistic")
	public SmartResult<CompanyCrowdsourceInvoiceBriefStatisticDto> companyCrowdsourceInvoiceStatistic(
			@RequestBody BaseSimpleFormBean<Integer> formBean) {
		return invoiceService.companyCrowdsourceInvoiceStatistic(formBean);
	}

	@ZddLog(type = ZddLogType.UPDATE, name = "确认智众包项目申请开票", entities = @LogEntity(entity = Invoice.class, parameters = @LogParameter))
	@ApiOperation("确认智众包项目申请开票(根据申请开票日期判断是否转为策略性开票)")
	@PostMapping("/confirmCrowdsourceInvoiceApply")
	public SmartResult confirmCrowdsourceInvoiceApply(@RequestBody BaseSimpleFormBean<List<Integer>> formBean) {
		return invoiceService.confirmCrowdsourceInvoiceApply(formBean);
	}

	@ZddLog(type = ZddLogType.UPDATE, name = "修改智众包项目申请开票日期", entities = {
			@LogEntity(entity = Invoice.class, parameters = @LogParameter(parameters = "formBean.reqdata.invoiceid")),
			@LogEntity(entity = CompanyProject.class, dependOnEntities = @DependOnEntity(entity = Invoice.class, fields = "projectid",
					parameters = "projectid"))})
	@ApiOperation("修改智众包项目申请开票日期")
	@PostMapping("/editCrowdsourceInvoiceApplyDate")
	public SmartResult editCrowdsourceInvoiceApplyDate(
			@Valid @RequestBody BaseSimpleFormBean<EditCrowdsourceApplyInvoiceDateFormBean> formBean) {
		return invoiceService.editCrowdsourceInvoiceApplyDate(formBean);
	}

	@ApiOperation(value = "下载发票列表", tags = "下载excel")
	@GetMapping("/downloadInvoiceList")
	public void downloadInvoiceList(HttpServletResponse response,
	                                @ApiParam(name = "name", value = "模糊搜索关键字") @RequestParam(name = "name", required = false) String name,
	                                @ApiParam(name = "startDate", value = "开始时间") @RequestParam(name = "startDate", required = false) Long start,
	                                @ApiParam(name = "endDate", value = "结束时间") @RequestParam(name = "endDate", required = false) Long end,
	                                @ApiParam(name = "state", value = "1.等待受理 2受理中 3已完成(出票) 4被拒绝") @RequestParam(name = "state", required
			                                = false, defaultValue = "0") int state,
	                                @ApiParam(name = "managerid", value = "操作人员managerid") @RequestParam(name = "managerid") int managerid)
			throws IOException {
		Date startDate = null, endDate = null;
		if (start != null) {
			startDate = new Date(start);
		}
		if (end != null) {
			endDate = new Date(end);
		}

		InvoiceListFromBean reqdata = new InvoiceListFromBean().setStartDate(startDate)
				.setEndDate(endDate)
				.setState(state)
				.setManagerid(managerid)
				.setName(name);
		invoiceService.downloadInvoiceList(response, reqdata);
	}

	@ZddLog(type = ZddLogType.UPDATE, name = "保存线下项目转账凭证", entities = @LogEntity(entity = Invoice.class, parameters =
	@LogParameter(parameters = "formBean.reqdata.id")))
	@ApiOperation("保存线下项目转账凭证")
	@PostMapping("/saveOfflinePayReceipt")
	public SmartResult saveOfflinePayReceipt(@RequestBody BaseSimpleFormBean<OfflinePayReceiptFormBean> formBean) {
		return invoiceService.saveOfflinePayReceipt(formBean);
	}

	@ZddLog(name = "添加编辑发票入库记录")
	@ApiOperation("添加编辑发票入库记录")
	@PostMapping("/addEditInventoryRecord")
	public SmartResult addEditInventoryRecord(@Valid @RequestBody BaseSimpleFormBean<AddEditInventoryRecordFormBean> formBean) {
		return invoiceService.addEditInventoryRecord(formBean);
	}

	@ZddLog(type = ZddLogType.UPDATE, name = "发票入库", entities = @LogEntity(entity = InvoiceInventoryRecord.class, parameters =
	@LogParameter(parameters = "formBean.reqdata[i]")))
	@ApiOperation("发票入库")
	@PostMapping("/entryInventory")
	public SmartResult entryInventory(@RequestBody BaseSimpleFormBean<String> formBean) {
		return invoiceService.entryInventory(formBean);
	}

	@ZddLog(type = ZddLogType.DELETE, name = "删除发票入库记录", entities = @LogEntity(entity = InvoiceInventoryRecord.class, parameters =
	@LogParameter))
	@ApiOperation("删除发票入库记录")
	@PostMapping("/deleteInventoryRecord")
	public SmartResult deleteInventoryRecord(@RequestBody BaseSimpleFormBean<Integer> formBean) {
		return invoiceService.deleteInventoryRecord(formBean);
	}

	@ApiOperation("发票库存列表")
	@PostMapping("/inventoryList")
	public SmartResult<InvoiceInventoryDto> getInventoryList(@RequestBody BaseSimpleFormBean<InventoryListFormBean> formBean) {
		return invoiceService.getInventoryList(formBean);
	}

	@ApiOperation("无发票库存并且有待开票金额列表")
	@PostMapping("/nothingInventoryList")
	public SmartResult<InvoiceInventoryDto> nothingInventoryList(@RequestBody BaseSimpleFormBean<InventoryListFormBean> formBean) {
		return invoiceService.nothingInventoryList(formBean);
	}

	@ApiOperation("发票入库记录列表")
	@PostMapping("/inventoryRecordList")
	public SmartResult<InvoiceInventoryRecordDto> getInventoryRecordList(
			@RequestBody BaseSimpleFormBean<InventoryRecordListFormBean> formBean) {
		return invoiceService.getInventoryRecordList(formBean);
	}

	@ApiOperation("智众包成本发票列表")
	@PostMapping("/gongQingInvoiceList")
	public SmartResult crowdsourceCostInvoiceList(@RequestBody BaseSimpleFormBean<CrowdsourceCostInvoiceListFromBean> formBean) {
		return invoiceService.crowdsourceCostInvoiceList(formBean);
	}

	@ApiOperation(value = "导出智众包成本发票列表", tags = "下载excel")
	@GetMapping("/exportInvoiceData")
	public void exportInvoiceData(HttpServletResponse response,
								  @ApiParam(name = "userType", value = "用户类型") @RequestParam(name = "userType",required = false, defaultValue = "0") int userType,
								  @ApiParam(name = "companyName", value = "公司名") @RequestParam(name = "companyName", required = false) String companyName,
								  @ApiParam(name = "userName", value = "用户名") @RequestParam(name = "userName", required = false) String userName,
								  @ApiParam(name = "startDate", value = "开始日期") @RequestParam(name = "startDate", required = false) Long start,
								  @ApiParam(name = "endDate", value = "结束日期") @RequestParam(name = "endDate", required = false) Long end,
								  @ApiParam(name = "startAmount", value = "起始金额") @RequestParam(name = "startAmount", required = false) String startAmount,
								  @ApiParam(name = "endAmount", value = "结束金额") @RequestParam(name = "endAmount", required = false) String endAmount,
								  @ApiParam(name = "state", value = "状态") @RequestParam(name = "state", required = false, defaultValue = "0" ) int state,
								  @ApiParam(name = "strategy", value = "战略") @RequestParam(name = "strategy", required = false, defaultValue = "0") int strategy,
								  @ApiParam(name = "managerid", value = "id") @RequestParam(name = "managerid", required = false, defaultValue = "0") int managerid,
								  @ApiParam(name = "sort", value = "种类") @RequestParam(name = "sort", required = false) String sort,
								  @ApiParam(name = "auth",value = "授权") @RequestParam(name = "auth",required = false, defaultValue = "0") int auth) throws Exception {
		Date startDate = null, endDate = null;
		if (start != null) {
			startDate = new Date(start);
		}
		if (end != null) {
			endDate = new Date(end);
		}

		invoiceService.exportInvoiceData(response,userType,companyName,userName, startDate,endDate,startAmount,endAmount,state,strategy,managerid,sort,auth);
	}

	/**
	 * 获取所有甲方信息
	 *
	 * @return
	 */
	@ApiOperation("获取所有甲方信息")
	@GetMapping("/partyCompanyList")
	public SmartResult partyCompanyList() {
		return invoiceService.partyCompanyList();
	}

	/**
	 * 根据众包城市获取申请开票时对应的甲方信息
	 *
	 * @param formBean
	 * @return
	 */
	@ApiOperation("根据众包城市获取申请开票时对应的甲方信息")
	@PostMapping("/getPartyCompany")
	public SmartResult getPartyCompany(@RequestBody BaseSimpleFormBean<GetCompanyPartyFromBean> formBean) {
		return invoiceService.getPartyCompany(formBean);
	}

	/**
	 * 正常申请开票
	 */
	@ZddLog(name = "申请开票-成本发票")
	@ApiOperation("申请开票-选择甲方信息，输入运营方名称,选择开票地")
	@PostMapping("/applyForCostInvoice")
	public SmartResult applyForCostInvoice(@RequestBody BaseSimpleFormBean<ApplyForCostInvoiceFormBean> formBean) {
		return invoiceService.applyForCostInvoice(formBean);
	}

	/**
	 * 完成开票
	 *
	 * @param formBean
	 * @return
	 */
	@ZddLog(type = ZddLogType.UPDATE, name = "成本发票——完成开票", entities = @LogEntity(entity = CrowdsourceInvoice.class, parameters =
	@LogParameter(fields = "id", parameters = "formBean.reqdata.id")))
	@ApiOperation("成本发票——完成开票")
	@PostMapping("/completeCostInvoice")
	public SmartResult completeCostInvoice(@RequestBody BaseSimpleFormBean<CompleteCostInvoiceFormBean> formBean) {
		return invoiceService.completeCostInvoice(formBean);
	}

	@ApiOperation("下载成本发票开票合同")
	@GetMapping("/downloadCostInvoiceContract")
	public void downloadCostInvoiceContract(HttpServletResponse response, @RequestParam int invoiceId) {
		docService.downloadCostInvoiceContract(response, invoiceId);
	}

	@ZddLog(type = ZddLogType.UPDATE, name = "成本发票——成本发票设置策略性待开票", entities = @LogEntity(entity = CrowdsourceInvoice.class, parameters =
	@LogParameter(parameters = "formBean.reqdata.invoiceid")))
	@ApiOperation("成本发票设置策略性待开票")
	@PostMapping("/setCostInvoiceToStrategy")
	public SmartResult setCostInvoiceToStrategy(@Valid @RequestBody BaseListFormBean<SetCostInvoiceToStrategyFormBean> formBean) {
		return invoiceService.setCostInvoiceToStrategy(formBean);
	}

	@ApiOperation("成本发票多条合并申请开票")
	@PostMapping("/mergeApplyForCostInvoice")
	public SmartResult mergeApplyForCostInvoice(@RequestBody BaseSimpleFormBean<MergeApplyForCostInvoiceFormBean> formBean) {
		return invoiceService.mergeApplyForCostInvoice(formBean);
	}

	@ApiOperation("成本发票-合并开票列表")
	@PostMapping("/mergeCostInvoiceList")
	public SmartResult<MergeCostInvoiceListDto> mergeCostInvoiceList(@RequestBody BaseSimpleFormBean<MergeCostInvoiceFrombean> formBean) {
		return invoiceService.mergeCostInvoiceList(formBean);
	}

	@ApiOperation("查看关联的所有单条成本发票信息")
	@PostMapping("/queryAllRelationCostInvoice")
	public SmartResult<CostInvoiceListDto> queryAllRelationCostInvoice(@RequestBody BaseSimpleFormBean<Integer> formBean) {
		return invoiceService.queryAllRelationCostInvoice(formBean);
	}

	@ApiOperation(value = "导出成本发票合并开票的明细", tags = "下载excel")
	@GetMapping("/exportMergeCostInvoiceInfo")
	public void exportMergeCostInvoiceInfo(HttpServletResponse response, int id) {
		invoiceService.exportMergeCostInvoiceInfo(response, id);
	}

	// ==================主体企业 发票库存管理===============

	@ApiOperation("主体企业发票库存列表")
	@PostMapping("/mainEnterpriseInventoryList")
	public SmartResult<CompanyInventoryDto> getMainEnterpriseInventoryList(
			@RequestBody BaseSimpleFormBean<InventoryListFormBean> formBean) {
		return invoiceService.getMainEnterpriseInventoryList(formBean);
	}

	@ApiOperation("主体企业发票入库记录列表")
	@PostMapping("/mainEnterpriseInventoryRecordList")
	public SmartResult<CompanyInventoryRecordDto> getMainEnterpriseInventoryRecordList(
			@RequestBody BaseSimpleFormBean<InventoryRecordListFormBean> formBean) {
		return invoiceService.getMainEnterpriseInventoryRecordList(formBean);
	}

	@ZddLog(name = "添加/编辑主体企业发票入库记录")
	@ApiOperation("添加/编辑主体企业发票入库记录")
	@PostMapping("/addEditMainEnterpriseInventoryRecord")
	public SmartResult addEditMainEnterpriseInventoryRecord(
			@Valid @RequestBody BaseSimpleFormBean<MainEnterpriseInventoryRecordFormBean> formBean) {
		return invoiceService.addEditMainEnterpriseInventoryRecord(formBean);
	}

	@ZddLog(type = ZddLogType.UPDATE, name = "主体企业发票入库", entities = @LogEntity(entity = CompanyInventoryRecord.class, parameters =
	@LogParameter(parameters = "formBean.reqdata[i]")))
	@ApiOperation("主体企业发票入库")
	@PostMapping("/entryCompanyInventory")
	public SmartResult entryCompanyInventory(@RequestBody BaseSimpleFormBean<String> formBean) {
		return invoiceService.entryCompanyInventory(formBean);
	}

	@ZddLog(type = ZddLogType.DELETE, name = "删除主体企业发票入库记录", entities = @LogEntity(entity = CompanyInventoryRecord.class, parameters =
	@LogParameter))
	@ApiOperation("删除主体企业发票入库记录")
	@PostMapping("/deleteCompanyInventoryRecord")
	public SmartResult deleteCompanyInventoryRecord(@RequestBody BaseSimpleFormBean<Integer> formBean) {
		return invoiceService.deleteCompanyInventoryRecord(formBean);
	}

	@ApiOperation("修复智众包成本发票数据")
	@GetMapping("/fixCrowdsourceInvoiceProjectItemId")
	public SmartResult fixCrowdsourceInvoiceProjectItemId() {
		invoiceService.fixCrowdsourceInvoiceProjectItemId();
		return SmartResult.success();
	}

	@ApiOperation("工作室开票总金额")
	@PostMapping("/querymakerInvoiceSumPrice")
	public SmartResult querymakerInvoiceSumPrice(@RequestBody BaseSimpleFormBean<QueryMakerInvoiceSumPriceFormBean> formBean) {
		return invoiceService.querymakerInvoiceSumPrice(formBean);
	}

	@ZddLog(type = ZddLogType.UPDATE, name = "编辑发票线下支付付款状态", entities = @LogEntity(entity = Invoice.class, parameters =
	@LogParameter(parameters = "formBean.reqdata.id")))
	@ApiOperation("编辑发票线下支付付款状态")
	@PostMapping("/editInvoiceOfflinePayState")
	public SmartResult editInvoiceOfflinePayState(@RequestBody BaseSimpleFormBean<EditInvoicePayStateFormBean> formBean) {
		return invoiceService.editInvoiceOfflinePayState(formBean);
	}

	@ApiOperation("线下银行模式发票查询接口")
	@PostMapping("/queryApplyInvoiceList")
	public SmartResult<QueryInvoiceDto> queryApplyInvoiceList(@Valid @RequestBody BaseSimpleFormBean<QueryInvoiceListFromBean> formBean) {
		return invoiceService.queryApplyInvoiceList(formBean);
	}

	@ApiOperation(value = "编辑委托接单项目发票(只能修改项目名、项目内容和发票内容)", notes = "返回成功，但list中有值，说明list中的这些发票是已经完成开票的，不能修改数据")
	@PostMapping("/editEntrustProjectInvoice")
	public SmartResult editEntrustProjectInvoice(@Valid @RequestBody BaseSimpleFormBean<EditEntrustProjectInvoiceFormBean> formBean) {
		return invoiceService.editEnturstProjectInvoice(formBean);
	}

	@ApiOperation("查询税源地列表")
	@PostMapping("/queryTaxSourceList")
	public SmartResult queryTaxSourceList() {
		return invoiceService.queryTaxSourceList();
	}

	@ZddLog(type = ZddLogType.UPDATE, name = "申请智零工发票", entities = @LogEntity(entity = Invoice.class, parameters =
	@LogParameter(parameters = "formBean.reqdata.id")))
	@ApiOperation("申请智零工发票")
	@PostMapping("/applyContractorInvoice")
	public SmartResult applyContractorInvoice(@Valid @RequestBody BaseSimpleFormBean<EditContractorInvoiceFormBean> formBean) {
		return invoiceService.applyContractorInvoice(formBean);
	}

	@ZddLog(type = ZddLogType.UPDATE, name = "确认智零工开票信息", entities = @LogEntity(entity = Invoice.class, parameters =
	@LogParameter(parameters = "formBean.reqdata.id")))
	@ApiOperation("确认智零工开票信息")
	@PostMapping("/confirmContractorInvoice")
	public SmartResult confirmContractorInvoice(@Valid @RequestBody BaseSimpleFormBean<EditContractorInvoiceFormBean> formBean) {
		return invoiceService.confirmContractorInvoice(formBean);
	}

	@ZddLog(type = ZddLogType.UPDATE, name = "作废智零工发票信息", entities = @LogEntity(entity = Invoice.class, parameters =
	@LogParameter(parameters = "formBean.reqdata.id")))
	@ApiOperation("作废智零工发票信息")
	@PostMapping("/cancelContractorInvoice")
	public SmartResult cancelContractorInvoice(@Valid @RequestBody BaseSimpleFormBean<EditContractorInvoiceFormBean> formBean) {
		return invoiceService.cancelContractorInvoice(formBean);
	}

	@ApiOperation("查询所有智零工发票列表")
	@PostMapping("/contractorInvoiceList")
	public SmartResult contractorInvoiceList(@Valid @RequestBody BaseSimpleFormBean<QueryContractorInvoiceFormBean> formBean) {
		return invoiceService.contractorInvoiceList(formBean);
	}

	@ApiOperation("添加购买方")
	@PostMapping("/addBuyer")
	public SmartResult addBuyer(@RequestBody BaseSimpleFormBean<PurchaseInformation> formBean) {
		return invoiceService.addBuyer(formBean);
	}
	@ApiOperation("删除购买方")
	@PostMapping("/deletionOfPurchaser")
	public SmartResult deletionOfPurchaser(@RequestBody BaseSimpleFormBean<PurchaseInformation> formBean) {
		return invoiceService.deletionOfPurchaser(formBean.getReqdata().getPurchaserId());
	}

	@ApiOperation("查询购买方")
	@PostMapping("/inquireAboutTheBuyer")
	public SmartResult inquireAboutTheBuyer(@RequestBody BaseSimpleFormBean<inquireAboutTheBuyerFormBean> formBean) {
		return invoiceService.inquireAboutTheBuyer(formBean);
	}

	@ApiOperation("查询购买方列表")
	@PostMapping("/inquireAboutTheBuyerList")
	public SmartResult inquireAboutTheBuyerList(@RequestBody BaseSimpleFormBean<inquireAboutTheBuyerFormBean> formBean) {
		return invoiceService.inquireAboutTheBuyerList(formBean);
	}

	@ApiOperation("添加购买发票记录")
	@PostMapping("/addPurchaseInvoiceRecord")
	public SmartResult addPurchaseInvoiceRecord(@RequestBody BaseSimpleFormBean<PurchaseInvoiceRecord> formBean) {
		return invoiceService.addPurchaseInvoiceRecord(formBean);
	}

	@ApiOperation("确认开票 || 保存证据链")
	@PostMapping("/confirmationOfBill")
	public SmartResult confirmationOfBill(@RequestBody BaseSimpleFormBean<inquireAboutTheBuyerFormBean> formBean) {
		return invoiceService.confirmationOfBill(formBean,1);
	}

	@ApiOperation("删除开票记录")
	@PostMapping("/deleteTheBillingRecord")
	public SmartResult deleteTheBillingRecord(@RequestBody BaseSimpleFormBean<inquireAboutTheBuyerFormBean> formBean) {
		return invoiceService.confirmationOfBill(formBean,2);
	}

	@ApiOperation("购买发票记录列表")
	@PostMapping("/purchaseInvoiceRecordList")
	public SmartResult purchaseInvoiceRecordList(@RequestBody BaseSimpleFormBean<inquireAboutTheBuyerFormBean> formBean) {
		return invoiceService.purchaseInvoiceRecordList(formBean);
	}

	@ZddLog(type = ZddLogType.CREATE, name = "上传30万审批截图")
	@ApiOperation("上传30万审批截图")
	@PostMapping("/approvalScreenshot")
	public SmartResult approvalScreenshot(@RequestBody BaseSimpleFormBean<ApprovalScreenshotFromBean> formBean) {
		return invoiceService.approvalScreenshot(formBean.getReqdata());
	}
	@ApiOperation("替换发票路径")
	@PostMapping("/replaceTheInvoicePath")
	public SmartResult replaceTheInvoicePath(@RequestBody BaseSimpleFormBean<TheInvocePathFromBean> formBean) {
		return invoiceService.replaceTheInvoicePath(formBean.getReqdata());
	}

	@ApiOperation("智零工待上传完税凭证")
	@PostMapping("/taxClearanceCertificate")
	public SmartResult<TaxClearanceCertificateDto> taxClearanceCertificate(@RequestBody BaseSimpleFormBean<TaxPaymentVoucherListFormBean> formBean) {
		return invoiceService.taxClearanceCertificate(formBean);
	}

	@ApiOperation("智零工待上传完税凭证")
	@PostMapping("/2123")
	public void weqq() {
		 invoiceService.overdueTaxForm();
	}
}
